package com.wang.article.controller;

import com.wang.article.api.model.dto.ArticleHomeDto;
import com.wang.article.service.IArticleService;
import com.wang.common.constants.ArticleConstants;
import com.wang.common.model.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * App端文章查询接口
 *
 * @author: wangning
 * @date: 2023/12/28 15:52
 */
@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {

    @Autowired
    private IArticleService articleService;

    /**
     *
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto articleHomeDto){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_MORE, articleHomeDto);
    }

    /**
     * 下拉加载更多
     *
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto articleHomeDto){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_MORE, articleHomeDto);
    }

    /**
     * 上划加载最新
     *
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto articleHomeDto){
        return articleService.load(ArticleConstants.LOADTYPE_LOAD_NEW, articleHomeDto);
    }

}
